<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="roomlist.css" type="text/css" charset="utf-8" />
        <title>Roomlist</title>
    </head>
    <body background="image/bgroomlist.png" style="background-repeat: no-repeat">

        <form method="POST" action="createroom.php">
            <div id="btcreateroom">
                <input type="submit" value="create room" />
            </div>
        </form>
        
        <form action="comment.php" method="POST">
            <div id="btcomment">
                <input type="submit" value="Comment"/>
            </div>
        </form>

        <form action="index.php" method="POST">
            <div id="btqiut">
            <input type="submit" value="    Quit    " />
            </div>
        </form>
        

       <div id="roomlist">
<?php
            

$link = mysql_connect("localhost","root","");
mysql_select_db("ilink");
/* DB connection omitted here... */

// I assumed that there are name and bio fields in myTable, and there'll always be some data to be retrieved.
$result = mysql_query("SELECT * FROM createroom");


// Total number of records returned from DB.
$num_total_cols = mysql_num_rows($result);
// How many columns would you like per row (# of <td> per <tr>)?
$num_cols_per_row = 1;
// Text to display in empty cells in case there are any. This can be empty or whatever you want, of course.
$str_no_record = 'you can add new room';

echo '<table border="0" width="745">';
echo '<th bgcolor="3399CC">'.'Roomname'.'</th>';
echo '<th bgcolor="3399CC">'.'Roomsubcript'.'</th>';
echo '<th bgcolor="3399CC">'.'Roomstatus'.'</th>';
// While there is any fetchable row left in the result,
while ($i < $num_total_cols) {
    
    echo '<tr>';
    // The inner for loop. This horizontally echos your records for specified times (in $num_cols_per_row).
    for ($j = 0; $j < $num_cols_per_row; $j++) {
        // Check if the result is still fetchable.
        if ($row = mysql_fetch_assoc($result)) {
            // Yes, it is. Fetch it and show the record in <td>.
            
            if($row['roomstatus']=="Public"){
                echo '<td width="200">'.'<a href="chat.php?roomname='.$row['roomname'].'">'.''.$row['roomname'].'</a>'.'</td>'.'<td width="500">'.' &nbsp;&nbsp;'.$row['roomsubcript'].'</td>'.'<td width="150">'.' &nbsp;&nbsp;'.$row['roomstatus'].'</td>';
            //<a href=\"submit_docs.php?prop_id=".$prop_id."\">
            }
            else{
                echo '<td width="200">'.'<a href="ckpasschat.php?roomname='.$row['roomname'].'">'.''.$row['roomname'].'</a>'.'</td>'.'<td width="500">'.' &nbsp;&nbsp;'.$row['roomsubcript'].'</td>'.'<td width="150">'.' &nbsp;&nbsp;'.$row['roomstatus'].'</td>';

            }

        }
        else {
            // Nope. No more record to show from the DB. Show the replacement text "N/A".
            echo '<td>'.$str_no_record.'</td>';
        }
        // This is to tell PHP how many records (including the empty cells) we echoed so far.
        $i++;
        
        //echo $x;
    }
    echo '</tr>';
}

echo '</table>';
            
mysql_close($link);

?>
     </div>
    </body>
</html>
